package com.line.api;

import com.line.model.pojo.AccessTokenPojo;
import com.line.service.api.IAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "授权模块", tags = "授权模块")
@RestController
@RequestMapping("/auth")
public class AuthController {

	@Autowired
	private IAuthService authService;

	@PostMapping("/token")
	@ApiOperation(value = "获取access_token", notes = "所有接口访问，都需要通过令牌才能访问，当前接口用于申请令牌", response = AccessTokenPojo.class)
	@ApiImplicitParams({ // 请求参数列表
			@ApiImplicitParam(name = "grantType", paramType = "query", value = "授权类型，分三种类型client_credentials/password/refresh_token", required = true, dataType = "string"), //
			@ApiImplicitParam(name = "appid", paramType = "query", value = "第三方用户唯一凭证", dataType = "string", required = true), //
			@ApiImplicitParam(name = "secret", paramType = "query", value = "第三方用户唯一凭证密钥，即appsecret", dataType = "string", required = true), //
	})
	public AccessTokenPojo token(String grantType, String appid, String secret) {
		return authService.token(grantType, appid, secret);
	}

}
